package com.jtjrenren.android.taxi.passenger.bean.api;


import com.library.utils.StringUtils;

/**
 * Created by Administrator on 2016/1/26.
 */
public class AppVersion {

    /**
     * VersionNo : 10
     * Introductions : 1.修复功能的某些bug 2.优化了系统
     * PlatForm : Android
     * DownloadHttp : http://img.i952169.com:8072/uploadapk/a.apk
     * FileSize : 8.8M
     * IsUpdate : 0
     */
    public static final int APP_UPDATE_NO = 0;
    public static final int APP_UPDATE_NEED = 1;
    public static final int APP_UPDATE_FORCE = 2;

    private String VersionNo;
    private String Introductions;
    private String PlatForm;
    private String DownloadHttp;
    private String FileSize;
    private String IsUpdate;

    /**
     * 检查app 是否需要更新
     *
     * @param versionMsg
     * @return
     */
    public int compareVersion(String versionMsg) {
        if (StringUtils.isEmpty(IsUpdate))
            IsUpdate = "0";
        int mode = APP_UPDATE_NO;

        if (!StringUtils.isEmpty(VersionNo)) {
            String[] nowVersion = versionMsg.split("\\.");
            String[] webVersion = VersionNo.split("\\.");
            for (int i = 0; i < 3; i++) {
                if (Integer.parseInt(webVersion[i]) > Integer.parseInt(nowVersion[i])) {
                    mode = APP_UPDATE_NEED;
                } else if (Integer.parseInt(webVersion[i]) < Integer.parseInt(nowVersion[i])) {
                    break;
                }
            }
        }

        if (Integer.parseInt(IsUpdate) == 1&&mode==APP_UPDATE_NEED) {
            mode = APP_UPDATE_FORCE;
        }

        return mode;
    }

    public void setVersionNo(String VersionNo) {
        this.VersionNo = VersionNo;
    }

    public void setIntroductions(String Introductions) {
        this.Introductions = Introductions;
    }

    public void setPlatForm(String PlatForm) {
        this.PlatForm = PlatForm;
    }

    public void setDownloadHttp(String DownloadHttp) {
        this.DownloadHttp = DownloadHttp;
    }

    public void setFileSize(String FileSize) {
        this.FileSize = FileSize;
    }

    public void setIsUpdate(String IsUpdate) {
        this.IsUpdate = IsUpdate;
    }

    public String getVersionNo() {
        return VersionNo;
    }

    public String getIntroductions() {
        return Introductions;
    }

    public String getPlatForm() {
        return PlatForm;
    }

    public String getDownloadHttp() {
        return DownloadHttp;
    }

    public String getFileSize() {
        return FileSize;
    }

    public String getIsUpdate() {
        return IsUpdate;
    }
}
